# This file replicates Figures 3A-C in the main text, as well as Figures A17-A22 in the Online Appendix
rm(list = ls())
# Set your path
# setwd("~/...")
setwd("C:/Users/heidland/Dropbox (MEDAM)/replication material EJPR")
rm(list=ls())
# You need the following packages
#require("glmnet") -> needs to be installed manually
#require("foreach")
#require("shape")
#remove.packages("FindIt")
#install.packages('FindIt', dependencies = TRUE)
library("tidyverse")
library("FindIt")
library("haven")
library("dplyr")
library("expss")
library("foreach")
library("RColorBrewer")
library("ggpubr")
library("ggplot2")
data <- read_dta("recoded data/conjoint_pooled.dta")
#head(data)
#is.data.frame(data)
data$policy_choice <- as.numeric(data$policy_choice)
data$task <- factor(data$task)
data$attribute1 <- factor(data$attribute1, levels = c(1, 2),
labels = c("some", "all"))
data$attribute2 <- factor(data$attribute2, levels = c(1, 2, 3),
labels = c("No support", "Turkish gov", "IOs and NGOs"))
data$attribute3 <- factor(data$attribute3, levels = c(1, 2, 3),
labels = c("one-to-one", "nobody", "limited"))
data$attribute4 <- factor(data$attribute4, levels = c(1, 2, 3),
labels = c("financial and operational", "relocation", "no support"))
data$attribute5 <- factor(data$attribute5, levels = c(1, 2),
labels = c("standard", "enhanced"))
data$country <- factor(data$country, levels=c(1,2,3),
labels = c("Germany", "Greece", "Turkey"))
## Specify the order of each factor
data$attribute1<- factor(data$attribute1,ordered=FALSE,levels=c("all", "some"))
data$attribute2 <- factor(data$attribute2,ordered=FALSE,levels=c("No support", "Turkish gov", "IOs and NGOs"))
data$attribute3 <- factor(data$attribute3,ordered=TRUE,levels=c("nobody", "limited", "one-to-one"))
data$attribute4 <- factor(data$attribute4,ordered=FALSE,levels=c("relocation", "no support", "financial and operational"))
data$attribute5 <- factor(data$attribute5,ordered=TRUE,levels=c("standard", "enhanced"))
# Label the variables
data = apply_labels(data,
attribute1 = "Returns",
attribute2 = "Financial support for Turkey",
attribute3 = "Resettlement",
attribute4 = "Support for Greece",
attribute5 = "Border controls by Turkey")
# Figures 3A-3C:
# Generate data subsets and estimate separate results for each country
# Note: Weights are not allowed in this type of analysis
countries <- c("Germany", "Greece", "Turkey")
for (c in countries){
print(c)
data_country=subset(data, country==paste0(c))
# Estimation
data_interactions_non_regul <- CausalANOVA(formula=policy_choice ~ attribute1 + attribute2 + attribute3 + attribute4 + attribute5,data=data_country, pair.id=data_country$caseID,cluster=data_country$caseID, diff=TRUE, nway=2)
data_interactions_non_regul <- summary(data_interactions_non_regul)[[4]]
# Plot
# To set the colors, identify the absolute maximum of the data
limit <- max(abs(data_interactions_non_regul$AMIE)) * c(-1, 1)
interactions_non_regul <- ggplot(data_interactions_non_regul, aes(y= Level2, x=Level1)) +
geom_raster(aes(fill=AMIE)) +
scale_fill_gradientn(colours=c("coral", "white", "dodgerblue"),
breaks=c(-0.03, -0.02, -0.01, 0, 0.01, 0.02, 0.03), limit=limit) +
labs(fill = "") +
theme(legend.position="top",
legend.key.width = unit(3,"cm"),
panel.background = element_rect(fill = "gray90"),
plot.title = element_text(size = 12, hjust = 0.5)) +
labs(y = "First attribute", x = "Second attribute") +
scale_y_discrete(labels = c("enhanced" = "Border controls: enhanced", "standard" = "Border controls: standard", "financial and operational" = "Support Greece: financial and operational",
"no support" = "Support Greece: no support", "relocation" = "Support Greece: relocation", "one-to-one" = "Resettlement: one-to-one", "limited" = "Resettlement: limited 1%", "nobody" = "Resettlement: nobody", "IOs and NGOs" = "Support Turkey: IOs and NGOs", "Turkish gov" = "Support Turkey: Turkish government", "No support" = "Support Turkey: no support", "all" = "Returns: all", "some" = "Returns: some")) +
scale_x_discrete(labels = c("enhanced" = "Border controls: enhanced", "standard" = "Border controls: standard", "financial and operational" = "Support Greece: financial and operational",
"no support" = "Support Greece: no support", "relocation" = "Support Greece: relocation", "one-to-one" = "Resettlement: one-to-one", "limited" = "Resettlement: limited 1%", "nobody" = "Resettlement: nobody", "IOs and NGOs" = "Support Turkey: IOs and NGOs", "Turkish gov" = "Support Turkey: Turkish government", "No support" = "Support Turkey: no support", "all" = "Returns: all", "some" = "Returns: some")) +
theme(axis.text.x = element_text(angle = 45, hjust=1))+
geom_vline(xintercept = 1.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 2.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 3.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 4.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 5.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 6.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 7.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 8.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 9.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 10.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 1.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 2.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 3.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 4.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 5.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 6.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 7.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 8.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 9.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 10.5, linetype="solid", color = "grey90", size=2)
assign(paste0("interactions_non_regul_",c), interactions_non_regul)
ggsave(filename = paste0("figures/main/Figure3_",c,".png"), plot=interactions_non_regul, device="png", width = 20, height = 20, units = "cm", dpi=600)
ggsave(filename = paste0("figures/main/Figure3_",c,".eps"), plot=interactions_non_regul, device="eps", width = 20, height = 20, units = "cm", dpi=600)
interactions_non_regul
}
interactions_non_regul
file.rename("figures/main/Figure3_Germany.png", "figures/main/Figure3A.png")
file.rename("figures/main/Figure3_Greece.png", "figures/main/Figure3B.png")
file.rename("figures/main/Figure3_Turkey.png", "figures/main/Figure3C.png")
file.rename("figures/main/Figure3_Germany.eps", "figures/main/Figure3A.eps")
file.rename("figures/main/Figure3_Greece.eps", "figures/main/Figure3B.eps")
file.rename("figures/main/Figure3_Turkey.eps", "figures/main/Figure3C.eps")
################################################################################################
# Figure A17-A19:
# By Country, separate estimation for above and below medians on left/right scale and pro/anti-immigration attitude, i.e. 12 graphs via two loops
countries <- c("Germany", "Greece", "Turkey")
for (ctry in countries){
print(ctry)
data_country=subset(data, country==paste0(ctry))
###############################
# Estimating separately for above and below medians on left/right
data_country$v_891<-replace(data_country$v_891, data_country$v_891==99, NA)
data_country$leftright_above_median <- factor(
ifelse(data_country$v_891 < median(data_country$v_891, na.rm = TRUE), 1,
ifelse(data_country$v_891 >= median(data_country$v_891, na.rm = TRUE), 2, NA)),
1:2, labels = c("below", "above"))
# Note: The median is 5 and many are at the median. So this includes the center
groups <- c("below", "above")
for (c in groups){
print(c)
data_subset=subset(data_country, leftright_above_median==paste0(c))
data_interactions_non_regul <- CausalANOVA(formula=policy_choice ~ attribute1 + attribute2 + attribute3 + attribute4 + attribute5,data=data_subset, pair.id=data_subset$caseID,cluster=data_subset$caseID, diff=TRUE, nway=2)
data_interactions_non_regul <- summary(data_interactions_non_regul)[[4]]
##### Plots #####
limit <- max(abs(data_interactions_non_regul$AMIE)) * c(-1, 1)
interactions_non_regul <- ggplot(data_interactions_non_regul, aes(y= Level2, x=Level1)) +
geom_raster(aes(fill=AMIE)) +
scale_fill_gradientn(colours=c("coral", "white", "dodgerblue"),
breaks=c(-0.03, -0.02, -0.01, 0, 0.01, 0.02, 0.03), limit=limit) +
labs(fill = "") +
theme(legend.position="top",
legend.key.width = unit(3,"cm"),
panel.background = element_rect(fill = "gray90"),
plot.title = element_text(size = 12, hjust = 0.5)) +
labs(y = "First attribute", x = "Second attribute") +
scale_y_discrete(labels = c("enhanced" = "Border controls: enhanced", "standard" = "Border controls: standard", "financial and operational" = "Support Greece: financial and operational",
"no support" = "Support Greece: no support", "relocation" = "Support Greece: relocation", "one-to-one" = "Resettlement: one-to-one", "limited" = "Resettlement: limited 1%", "nobody" = "Resettlement: nobody", "IOs and NGOs" = "Support Turkey: IOs and NGOs", "Turkish gov" = "Support Turkey: Turkish government", "No support" = "Support Turkey: no support", "all" = "Returns: all", "some" = "Returns: some")) +
scale_x_discrete(labels = c("enhanced" = "Border controls: enhanced", "standard" = "Border controls: standard", "financial and operational" = "Support Greece: financial and operational",
"no support" = "Support Greece: no support", "relocation" = "Support Greece: relocation", "one-to-one" = "Resettlement: one-to-one", "limited" = "Resettlement: limited 1%", "nobody" = "Resettlement: nobody", "IOs and NGOs" = "Support Turkey: IOs and NGOs", "Turkish gov" = "Support Turkey: Turkish government", "No support" = "Support Turkey: no support", "all" = "Returns: all", "some" = "Returns: some")) +
theme(axis.text.x = element_text(angle = 45, hjust=1))+
geom_vline(xintercept = 1.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 2.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 3.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 4.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 5.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 6.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 7.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 8.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 9.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 10.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 1.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 2.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 3.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 4.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 5.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 6.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 7.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 8.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 9.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 10.5, linetype="solid", color = "grey90", size=2)
assign(paste0("interactions_non_regul_",c), interactions_non_regul)
##### Separate Graphics #####
ggsave(filename = paste0("figures/appendix/FigureA17-A19_",c,"_",ctry,".png"), plot=interactions_non_regul, device="png", width = 20, height = 20, units = "cm", dpi=600)
ggsave(filename = paste0("figures/appendix/FigureA17-A19_",c,"_",ctry,".eps"), plot=interactions_non_regul, device="eps", width = 20, height = 20, units = "cm", dpi=600)
interactions_non_regul
}
#### Anti-/Pro-Immigration attitude
data_country$v_840<-replace(data_country$v_840, data_country$v_840==99, NA)
data_country$proanti <- factor(
ifelse(data_country$v_840 < median(data_country$v_840, na.rm = TRUE), 1,
ifelse(data_country$v_840 >= median(data_country$v_840, na.rm = TRUE), 2, NA)),
1:2, labels = c("below", "above"))
# Note: The median is 5 and many are at the median. So this includes the center
groups <- c("below", "above")
for (c in groups){
print(c)
data_subset=subset(data_country, proanti==paste0(c))
data_interactions_non_regul <- CausalANOVA(formula=policy_choice ~ attribute1 + attribute2 + attribute3 + attribute4 + attribute5,data=data_subset, pair.id=data_subset$caseID,cluster=data_subset$caseID, diff=TRUE, nway=2)
data_interactions_non_regul <- summary(data_interactions_non_regul)[[4]]
##### Plots #####
limit <- max(abs(data_interactions_non_regul$AMIE)) * c(-1, 1)
interactions_non_regul <- ggplot(data_interactions_non_regul, aes(y= Level2, x=Level1)) +
geom_raster(aes(fill=AMIE)) +
scale_fill_gradientn(colours=c("coral", "white", "dodgerblue"),
breaks=c(-0.03, -0.02, -0.01, 0, 0.01, 0.02, 0.03), limit=limit) +
labs(fill = "") +
theme(legend.position="top",
legend.key.width = unit(3,"cm"),
panel.background = element_rect(fill = "gray90"),
plot.title = element_text(size = 12, hjust = 0.5)) +
labs(y = "First attribute", x = "Second attribute") +
scale_y_discrete(labels = c("enhanced" = "Border controls: enhanced", "standard" = "Border controls: standard", "financial and operational" = "Support Greece: financial and operational",
"no support" = "Support Greece: no support", "relocation" = "Support Greece: relocation", "one-to-one" = "Resettlement: one-to-one", "limited" = "Resettlement: limited 1%", "nobody" = "Resettlement: nobody", "IOs and NGOs" = "Support Turkey: IOs and NGOs", "Turkish gov" = "Support Turkey: Turkish government", "No support" = "Support Turkey: no support", "all" = "Returns: all", "some" = "Returns: some")) +
scale_x_discrete(labels = c("enhanced" = "Border controls: enhanced", "standard" = "Border controls: standard", "financial and operational" = "Support Greece: financial and operational",
"no support" = "Support Greece: no support", "relocation" = "Support Greece: relocation", "one-to-one" = "Resettlement: one-to-one", "limited" = "Resettlement: limited 1%", "nobody" = "Resettlement: nobody", "IOs and NGOs" = "Support Turkey: IOs and NGOs", "Turkish gov" = "Support Turkey: Turkish government", "No support" = "Support Turkey: no support", "all" = "Returns: all", "some" = "Returns: some")) +
theme(axis.text.x = element_text(angle = 45, hjust=1))+
geom_vline(xintercept = 1.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 2.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 3.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 4.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 5.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 6.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 7.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 8.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 9.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 10.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 1.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 2.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 3.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 4.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 5.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 6.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 7.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 8.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 9.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 10.5, linetype="solid", color = "grey90", size=2)
assign(paste0("interactions_non_regul_",c), interactions_non_regul)
ggsave(filename = paste0("figures/appendix/FigureA20-A22_",c,"_",ctry,".png"), plot=interactions_non_regul, device="png", width = 20, height = 20, units = "cm", dpi=600)
ggsave(filename = paste0("figures/appendix/FigureA20-A22_",c,"_",ctry,".eps"), plot=interactions_non_regul, device="eps", width = 20, height = 20, units = "cm", dpi=600)
interactions_non_regul
}
}
# Rename files
file.rename("figures/appendix/FigureA17-A19_below_Germany.png", "figures/appendix/FigureA17_leftpanel.png")
file.rename("figures/appendix/FigureA17-A19_below_Greece.png", "figures/appendix/FigureA18_leftpanel.png")
file.rename("figures/appendix/FigureA17-A19_below_Turkey.png", "figures/appendix/FigureA19_leftpanel.png")
file.rename("figures/appendix/FigureA20-A22_below_Germany.png", "figures/appendix/FigureA20_leftpanel.png")
file.rename("figures/appendix/FigureA20-A22_below_Greece.png", "figures/appendix/FigureA21_leftpanel.png")
file.rename("figures/appendix/FigureA20-A22_below_Turkey.png", "figures/appendix/FigureA22_leftpanel.png")
file.rename("figures/appendix/FigureA17-A19_above_Germany.png", "figures/appendix/FigureA17_rightpanel.png")
file.rename("figures/appendix/FigureA17-A19_above_Greece.png", "figures/appendix/FigureA18_rightpanel.png")
file.rename("figures/appendix/FigureA17-A19_above_Turkey.png", "figures/appendix/FigureA19_rightpanel.png")
file.rename("figures/appendix/FigureA20-A22_above_Germany.png", "figures/appendix/FigureA20_rightpanel.png")
file.rename("figures/appendix/FigureA20-A22_above_Greece.png", "figures/appendix/FigureA21_rightpanel.png")
file.rename("figures/appendix/FigureA20-A22_above_Turkey.png", "figures/appendix/FigureA22_rightpanel.png")
file.rename("figures/appendix/FigureA17-A19_below_Germany.eps", "figures/appendix/FigureA17_leftpanel.eps")
file.rename("figures/appendix/FigureA17-A19_below_Greece.eps", "figures/appendix/FigureA18_leftpanel.eps")
file.rename("figures/appendix/FigureA17-A19_below_Turkey.eps", "figures/appendix/FigureA19_leftpanel.eps")
file.rename("figures/appendix/FigureA20-A22_below_Germany.eps", "figures/appendix/FigureA20_leftpanel.eps")
file.rename("figures/appendix/FigureA20-A22_below_Greece.eps", "figures/appendix/FigureA21_leftpanel.eps")
file.rename("figures/appendix/FigureA20-A22_below_Turkey.eps", "figures/appendix/FigureA22_leftpanel.eps")
file.rename("figures/appendix/FigureA17-A19_above_Germany.eps", "figures/appendix/FigureA17_rightpanel.eps")
file.rename("figures/appendix/FigureA17-A19_above_Greece.eps", "figures/appendix/FigureA18_rightpanel.eps")
file.rename("figures/appendix/FigureA17-A19_above_Turkey.eps", "figures/appendix/FigureA19_rightpanel.eps")
file.rename("figures/appendix/FigureA20-A22_above_Germany.eps", "figures/appendix/FigureA20_rightpanel.eps")
file.rename("figures/appendix/FigureA20-A22_above_Greece.eps", "figures/appendix/FigureA21_rightpanel.eps")
file.rename("figures/appendix/FigureA20-A22_above_Turkey.eps", "figures/appendix/FigureA22_rightpanel.eps")
# This file replicates Figures 3A-C in the main text, as well as Figures A17-A22 in the Online Appendix
rm(list = ls())
# Set your path
# setwd("~/...")
setwd("C:/Users/heidland/Dropbox (MEDAM)/replication material EJPR")
rm(list=ls())
# You need the following packages
#require("glmnet") -> needs to be installed manually
#require("foreach")
#require("shape")
#remove.packages("FindIt")
#install.packages('FindIt', dependencies = TRUE)
library("tidyverse")
library("FindIt")
library("haven")
library("dplyr")
library("expss")
library("foreach")
library("RColorBrewer")
library("ggpubr")
library("ggplot2")
data <- read_dta("recoded data/conjoint_pooled.dta")
#head(data)
#is.data.frame(data)
data$policy_choice <- as.numeric(data$policy_choice)
data$task <- factor(data$task)
data$attribute1 <- factor(data$attribute1, levels = c(1, 2),
labels = c("some", "all"))
data$attribute2 <- factor(data$attribute2, levels = c(1, 2, 3),
labels = c("No support", "Turkish gov", "IOs and NGOs"))
data$attribute3 <- factor(data$attribute3, levels = c(1, 2, 3),
labels = c("one-to-one", "nobody", "limited"))
data$attribute4 <- factor(data$attribute4, levels = c(1, 2, 3),
labels = c("financial and operational", "relocation", "no support"))
data$attribute5 <- factor(data$attribute5, levels = c(1, 2),
labels = c("standard", "enhanced"))
data$country <- factor(data$country, levels=c(1,2,3),
labels = c("Germany", "Greece", "Turkey"))
## Specify the order of each factor
data$attribute1<- factor(data$attribute1,ordered=FALSE,levels=c("all", "some"))
data$attribute2 <- factor(data$attribute2,ordered=FALSE,levels=c("No support", "Turkish gov", "IOs and NGOs"))
data$attribute3 <- factor(data$attribute3,ordered=TRUE,levels=c("nobody", "limited", "one-to-one"))
data$attribute4 <- factor(data$attribute4,ordered=FALSE,levels=c("relocation", "no support", "financial and operational"))
data$attribute5 <- factor(data$attribute5,ordered=TRUE,levels=c("standard", "enhanced"))
# Label the variables
data = apply_labels(data,
attribute1 = "Returns",
attribute2 = "Financial support for Turkey",
attribute3 = "Resettlement",
attribute4 = "Support for Greece",
attribute5 = "Border controls by Turkey")
# Figures 3A-3C:
# Generate data subsets and estimate separate results for each country
# Note: Weights are not allowed in this type of analysis
countries <- c("Germany", "Greece", "Turkey")
for (c in countries){
print(c)
data_country=subset(data, country==paste0(c))
# Estimation
data_interactions_non_regul <- CausalANOVA(formula=policy_choice ~ attribute1 + attribute2 + attribute3 + attribute4 + attribute5,data=data_country, pair.id=data_country$caseID,cluster=data_country$caseID, diff=TRUE, nway=2)
data_interactions_non_regul <- summary(data_interactions_non_regul)[[4]]
# Plot
# To set the colors, identify the absolute maximum of the data
limit <- max(abs(data_interactions_non_regul$AMIE)) * c(-1, 1)
interactions_non_regul <- ggplot(data_interactions_non_regul, aes(y= Level2, x=Level1)) +
geom_raster(aes(fill=AMIE)) +
scale_fill_gradientn(colours=c("coral", "white", "dodgerblue"),
breaks=c(-0.03, -0.02, -0.01, 0, 0.01, 0.02, 0.03), limit=limit) +
labs(fill = "") +
theme(legend.position="top",
legend.key.width = unit(3,"cm"),
panel.background = element_rect(fill = "gray90"),
plot.title = element_text(size = 12, hjust = 0.5)) +
labs(y = "First attribute", x = "Second attribute") +
scale_y_discrete(labels = c("enhanced" = "Border controls: enhanced", "standard" = "Border controls: standard", "financial and operational" = "Support Greece: financial and operational",
"no support" = "Support Greece: no support", "relocation" = "Support Greece: relocation", "one-to-one" = "Resettlement: one-to-one", "limited" = "Resettlement: limited 1%", "nobody" = "Resettlement: nobody", "IOs and NGOs" = "Support Turkey: IOs and NGOs", "Turkish gov" = "Support Turkey: Turkish government", "No support" = "Support Turkey: no support", "all" = "Returns: all", "some" = "Returns: some")) +
scale_x_discrete(labels = c("enhanced" = "Border controls: enhanced", "standard" = "Border controls: standard", "financial and operational" = "Support Greece: financial and operational",
"no support" = "Support Greece: no support", "relocation" = "Support Greece: relocation", "one-to-one" = "Resettlement: one-to-one", "limited" = "Resettlement: limited 1%", "nobody" = "Resettlement: nobody", "IOs and NGOs" = "Support Turkey: IOs and NGOs", "Turkish gov" = "Support Turkey: Turkish government", "No support" = "Support Turkey: no support", "all" = "Returns: all", "some" = "Returns: some")) +
theme(axis.text.x = element_text(angle = 45, hjust=1))+
geom_vline(xintercept = 1.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 2.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 3.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 4.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 5.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 6.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 7.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 8.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 9.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 10.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 1.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 2.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 3.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 4.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 5.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 6.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 7.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 8.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 9.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 10.5, linetype="solid", color = "grey90", size=2)
assign(paste0("interactions_non_regul_",c), interactions_non_regul)
ggsave(filename = paste0("figures/main/figure3_",c,".pdf"), plot=interactions_non_regul, device="pdf", width = 20, height = 20, units = "cm", dpi=600)
ggsave(filename = paste0("figures/main/figure3_",c,".eps"), plot=interactions_non_regul, device="eps", width = 20, height = 20, units = "cm", dpi=600)
interactions_non_regul
}
interactions_non_regul
file.rename("figures/main/figure3_Germany.pdf", "figures/main/figure3A.pdf")
file.rename("figures/main/figure3_Greece.pdf", "figures/main/figure3B.pdf")
file.rename("figures/main/figure3_Turkey.pdf", "figures/main/figure3C.pdf")
file.rename("figures/main/figure3_Germany.eps", "figures/main/figure3A.eps")
file.rename("figures/main/figure3_Greece.eps", "figures/main/figure3B.eps")
file.rename("figures/main/figure3_Turkey.eps", "figures/main/figure3C.eps")
################################################################################################
# Figure A17-A19:
# By Country, separate estimation for above and below medians on left/right scale and pro/anti-immigration attitude, i.e. 12 graphs via two loops
countries <- c("Germany", "Greece", "Turkey")
for (ctry in countries){
print(ctry)
data_country=subset(data, country==paste0(ctry))
###############################
# Estimating separately for above and below medians on left/right
data_country$v_891<-replace(data_country$v_891, data_country$v_891==99, NA)
data_country$leftright_above_median <- factor(
ifelse(data_country$v_891 < median(data_country$v_891, na.rm = TRUE), 1,
ifelse(data_country$v_891 >= median(data_country$v_891, na.rm = TRUE), 2, NA)),
1:2, labels = c("below", "above"))
# Note: The median is 5 and many are at the median. So this includes the center
groups <- c("below", "above")
for (c in groups){
print(c)
data_subset=subset(data_country, leftright_above_median==paste0(c))
data_interactions_non_regul <- CausalANOVA(formula=policy_choice ~ attribute1 + attribute2 + attribute3 + attribute4 + attribute5,data=data_subset, pair.id=data_subset$caseID,cluster=data_subset$caseID, diff=TRUE, nway=2)
data_interactions_non_regul <- summary(data_interactions_non_regul)[[4]]
##### Plots #####
limit <- max(abs(data_interactions_non_regul$AMIE)) * c(-1, 1)
interactions_non_regul <- ggplot(data_interactions_non_regul, aes(y= Level2, x=Level1)) +
geom_raster(aes(fill=AMIE)) +
scale_fill_gradientn(colours=c("coral", "white", "dodgerblue"),
breaks=c(-0.03, -0.02, -0.01, 0, 0.01, 0.02, 0.03), limit=limit) +
labs(fill = "") +
theme(legend.position="top",
legend.key.width = unit(3,"cm"),
panel.background = element_rect(fill = "gray90"),
plot.title = element_text(size = 12, hjust = 0.5)) +
labs(y = "First attribute", x = "Second attribute") +
scale_y_discrete(labels = c("enhanced" = "Border controls: enhanced", "standard" = "Border controls: standard", "financial and operational" = "Support Greece: financial and operational",
"no support" = "Support Greece: no support", "relocation" = "Support Greece: relocation", "one-to-one" = "Resettlement: one-to-one", "limited" = "Resettlement: limited 1%", "nobody" = "Resettlement: nobody", "IOs and NGOs" = "Support Turkey: IOs and NGOs", "Turkish gov" = "Support Turkey: Turkish government", "No support" = "Support Turkey: no support", "all" = "Returns: all", "some" = "Returns: some")) +
scale_x_discrete(labels = c("enhanced" = "Border controls: enhanced", "standard" = "Border controls: standard", "financial and operational" = "Support Greece: financial and operational",
"no support" = "Support Greece: no support", "relocation" = "Support Greece: relocation", "one-to-one" = "Resettlement: one-to-one", "limited" = "Resettlement: limited 1%", "nobody" = "Resettlement: nobody", "IOs and NGOs" = "Support Turkey: IOs and NGOs", "Turkish gov" = "Support Turkey: Turkish government", "No support" = "Support Turkey: no support", "all" = "Returns: all", "some" = "Returns: some")) +
theme(axis.text.x = element_text(angle = 45, hjust=1))+
geom_vline(xintercept = 1.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 2.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 3.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 4.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 5.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 6.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 7.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 8.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 9.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 10.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 1.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 2.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 3.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 4.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 5.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 6.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 7.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 8.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 9.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 10.5, linetype="solid", color = "grey90", size=2)
assign(paste0("interactions_non_regul_",c), interactions_non_regul)
##### Separate Graphics #####
ggsave(filename = paste0("figures/appendix/figureA17-A19_",c,"_",ctry,".pdf"), plot=interactions_non_regul, device="pdf", width = 20, height = 20, units = "cm", dpi=600)
ggsave(filename = paste0("figures/appendix/figureA17-A19_",c,"_",ctry,".eps"), plot=interactions_non_regul, device="eps", width = 20, height = 20, units = "cm", dpi=600)
interactions_non_regul
}
#### Anti-/Pro-Immigration attitude
data_country$v_840<-replace(data_country$v_840, data_country$v_840==99, NA)
data_country$proanti <- factor(
ifelse(data_country$v_840 < median(data_country$v_840, na.rm = TRUE), 1,
ifelse(data_country$v_840 >= median(data_country$v_840, na.rm = TRUE), 2, NA)),
1:2, labels = c("below", "above"))
# Note: The median is 5 and many are at the median. So this includes the center
groups <- c("below", "above")
for (c in groups){
print(c)
data_subset=subset(data_country, proanti==paste0(c))
data_interactions_non_regul <- CausalANOVA(formula=policy_choice ~ attribute1 + attribute2 + attribute3 + attribute4 + attribute5,data=data_subset, pair.id=data_subset$caseID,cluster=data_subset$caseID, diff=TRUE, nway=2)
data_interactions_non_regul <- summary(data_interactions_non_regul)[[4]]
##### Plots #####
limit <- max(abs(data_interactions_non_regul$AMIE)) * c(-1, 1)
interactions_non_regul <- ggplot(data_interactions_non_regul, aes(y= Level2, x=Level1)) +
geom_raster(aes(fill=AMIE)) +
scale_fill_gradientn(colours=c("coral", "white", "dodgerblue"),
breaks=c(-0.03, -0.02, -0.01, 0, 0.01, 0.02, 0.03), limit=limit) +
labs(fill = "") +
theme(legend.position="top",
legend.key.width = unit(3,"cm"),
panel.background = element_rect(fill = "gray90"),
plot.title = element_text(size = 12, hjust = 0.5)) +
labs(y = "First attribute", x = "Second attribute") +
scale_y_discrete(labels = c("enhanced" = "Border controls: enhanced", "standard" = "Border controls: standard", "financial and operational" = "Support Greece: financial and operational",
"no support" = "Support Greece: no support", "relocation" = "Support Greece: relocation", "one-to-one" = "Resettlement: one-to-one", "limited" = "Resettlement: limited 1%", "nobody" = "Resettlement: nobody", "IOs and NGOs" = "Support Turkey: IOs and NGOs", "Turkish gov" = "Support Turkey: Turkish government", "No support" = "Support Turkey: no support", "all" = "Returns: all", "some" = "Returns: some")) +
scale_x_discrete(labels = c("enhanced" = "Border controls: enhanced", "standard" = "Border controls: standard", "financial and operational" = "Support Greece: financial and operational",
"no support" = "Support Greece: no support", "relocation" = "Support Greece: relocation", "one-to-one" = "Resettlement: one-to-one", "limited" = "Resettlement: limited 1%", "nobody" = "Resettlement: nobody", "IOs and NGOs" = "Support Turkey: IOs and NGOs", "Turkish gov" = "Support Turkey: Turkish government", "No support" = "Support Turkey: no support", "all" = "Returns: all", "some" = "Returns: some")) +
theme(axis.text.x = element_text(angle = 45, hjust=1))+
geom_vline(xintercept = 1.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 2.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 3.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 4.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 5.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 6.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 7.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 8.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 9.5, linetype="solid", color = "grey90", size=2) +
geom_vline(xintercept = 10.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 1.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 2.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 3.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 4.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 5.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 6.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 7.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 8.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 9.5, linetype="solid", color = "grey90", size=2) +
geom_hline(yintercept = 10.5, linetype="solid", color = "grey90", size=2)
assign(paste0("interactions_non_regul_",c), interactions_non_regul)
ggsave(filename = paste0("figures/appendix/figureA20-A22_",c,"_",ctry,".pdf"), plot=interactions_non_regul, device="pdf", width = 20, height = 20, units = "cm", dpi=600)
ggsave(filename = paste0("figures/appendix/figureA20-A22_",c,"_",ctry,".eps"), plot=interactions_non_regul, device="eps", width = 20, height = 20, units = "cm", dpi=600)
interactions_non_regul
}
}
# Rename files
file.rename("figures/appendix/figureA17-A19_below_Germany.pdf", "figures/appendix/figureA17_leftpanel.pdf")
file.rename("figures/appendix/figureA17-A19_below_Greece.pdf", "figures/appendix/figureA18_leftpanel.pdf")
file.rename("figures/appendix/figureA17-A19_below_Turkey.pdf", "figures/appendix/figureA19_leftpanel.pdf")
file.rename("figures/appendix/figureA20-A22_below_Germany.pdf", "figures/appendix/figureA20_leftpanel.pdf")
file.rename("figures/appendix/figureA20-A22_below_Greece.pdf", "figures/appendix/figureA21_leftpanel.pdf")
file.rename("figures/appendix/figureA20-A22_below_Turkey.pdf", "figures/appendix/figureA22_leftpanel.pdf")
file.rename("figures/appendix/figureA17-A19_above_Germany.pdf", "figures/appendix/figureA17_rightpanel.pdf")
file.rename("figures/appendix/figureA17-A19_above_Greece.pdf", "figures/appendix/figureA18_rightpanel.pdf")
file.rename("figures/appendix/figureA17-A19_above_Turkey.pdf", "figures/appendix/figureA19_rightpanel.pdf")
file.rename("figures/appendix/figureA20-A22_above_Germany.pdf", "figures/appendix/figureA20_rightpanel.pdf")
file.rename("figures/appendix/figureA20-A22_above_Greece.pdf", "figures/appendix/figureA21_rightpanel.pdf")
file.rename("figures/appendix/figureA20-A22_above_Turkey.pdf", "figures/appendix/figureA22_rightpanel.pdf")
file.rename("figures/appendix/figureA17-A19_below_Germany.eps", "figures/appendix/figureA17_leftpanel.eps")
file.rename("figures/appendix/figureA17-A19_below_Greece.eps", "figures/appendix/figureA18_leftpanel.eps")
file.rename("figures/appendix/figureA17-A19_below_Turkey.eps", "figures/appendix/figureA19_leftpanel.eps")
file.rename("figures/appendix/figureA20-A22_below_Germany.eps", "figures/appendix/figureA20_leftpanel.eps")
file.rename("figures/appendix/figureA20-A22_below_Greece.eps", "figures/appendix/figureA21_leftpanel.eps")
file.rename("figures/appendix/figureA20-A22_below_Turkey.eps", "figures/appendix/figureA22_leftpanel.eps")
file.rename("figures/appendix/figureA17-A19_above_Germany.eps", "figures/appendix/figureA17_rightpanel.eps")
file.rename("figures/appendix/figureA17-A19_above_Greece.eps", "figures/appendix/figureA18_rightpanel.eps")
file.rename("figures/appendix/figureA17-A19_above_Turkey.eps", "figures/appendix/figureA19_rightpanel.eps")
file.rename("figures/appendix/figureA20-A22_above_Germany.eps", "figures/appendix/figureA20_rightpanel.eps")
file.rename("figures/appendix/figureA20-A22_above_Greece.eps", "figures/appendix/figureA21_rightpanel.eps")
file.rename("figures/appendix/figureA20-A22_above_Turkey.eps", "figures/appendix/figureA22_rightpanel.eps")
